public class sushu {
    public static void main(String[] args) {
        int limit = 20000;
        SHUSU(limit);
    }
    public static void SHUSU(int limit) {
        boolean[] isPrime = new boolean[limit + 1];


        for (int i = 2; i <= limit; i++) {
            isPrime[i] = true;
        }


        for (int i = 2; i * i <= limit; i++) {
            if (isPrime[i]) {
                for (int j = i * i; j <= limit; j += i) {
                    isPrime[j] = false;
                }
            }
        }

        int count = 0;
        for (int i = 2; i <= limit; i++) {
            if (isPrime[i]) {
                System.out.printf("%5d", i);
                count++;
                if (count % 5 == 0) {
                    System.out.println();
                }
            }
        }


        if (count % 5 != 0) {
            System.out.println();
        }
    }
}
